package com.byron.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.byron.dao.UserDao;
import com.byron.model.User;

@Repository
public class UserDaoImpl implements UserDao {

    @Autowired
    private SessionFactory sessionFactory;

    @SuppressWarnings("unchecked")
    public List<User> findUserByName(String userName) {
        String sql = " from User";
        return (List<User>) sessionFactory.getCurrentSession().createQuery(sql).list();
    }

    @Override
    public void save(User user) {
        
        // TODO Auto-generated method stub
        sessionFactory.getCurrentSession().save(user);
    }

}